Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.3K
Views
ERROR: Named volume "mongodb:/data/db:rw" is used in service "mongo" but no declaration was found in the volumes section

I just start learning Docker recently. Trying to set up a service that stores database.

Here's my docker-compose.yml:

version: "3.7"

services:
  mongo:
    image: mongo
    ports:
    - 27018:27017
    volumes:
    - mongodb:/data/db

volumes:
  mongo:

As I run docker-compose up ., I got this error:

ERROR: Named volume "mongodb:/data/db:rw" is used in service "mongo" but no declaration was found in the volumes section.

And I did create my named volume mongodb outside. Running docker volume ls would give me:

DRIVER    VOLUME NAME
local     mongodb

Any ideas? Thanks alot.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

For named volumes you should have a "volumes" key on a same level as "services", and any named volumes you are using in your services have to be listed under the "volumes" key (where you missed).

in your case :

version: "3.7"

services:
  mongo:
    image: mongo
    ports:
    - 27018:27017
    volumes:
    - mongodb:/data/db

volumes:
  mongodb:

Just a reminder : anonymous volumes, and bind mounts don't need to be specified here.

hope this helped you :)

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!